<!DOCTYPE html>
<html>
	<head>
		<include file="public:meta" />
		<link rel="stylesheet" href="../public/css/personal.css">
	</head>
	<body>
		<include file="public:header"/>
		<div class="list_height plist-txt notarrow">
	        <div class="pic"></div>
	        <div class="tit font14">公司名称<span class="font_red_light">*</span></div>
	        <div class="describe font13">
	            <input type="text" id="companyname" id="companyname" placeholder="请输入公司名称" value="{$info['companyname']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
	    </div>
	    <div class="list_height plist-txt notarrow">
	        <div class="pic"></div>
	        <div class="tit font14">职位名称<span class="font_red_light">*</span></div>
	        <div class="describe font13">
	            <input type="text" id="jobs" id="jobs" placeholder="请输入职位名称" value="{$info['jobs']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
	    </div>
	    <div class="list_height plist-txt js-actionParent">
	        <div class="pic"></div>
	        <div class="tit font14">开始时间<span class="font_red_light">*</span></div>
	        <div class="describe font13 qs-temp-date js-showActionSheet" data-type="start">
		        <span class="f-date-txt-start">
	        	<if condition="$Think.get.id eq ''">
	        		请选择
	        	<elseif condition="$info['tonowEdu']"/>
	        		至今
				<else/>
					{$info.startyear}年-{$info.startmonth}月
	        	</if>
			        </span>
	        	<input type="hidden" class="f-year-code-start" id="startyear"  value="{$info['startyear']}">
						<input type="hidden" class="f-month-code-start" id="startmonth"  value="{$info['startmonth']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
		    <!--BEGIN actionSheet-->
		    <div>
			    <div class="qs-mask" style="display:none"></div>
			    <div class="qs-actionsheet js-actionsheet">
				    <div class="qs-actionsheet-menu">
					    <div class="con-filter">
						    <div class="f-selected-group">
							    <div class="s-bar">
								    <div class="s-bar-title qs-left">开始时间</div>
								    <div class="clear"></div>
							    </div>
							    <div class="s-list"></div>
						    </div>
						    <div class="f-box f-box-date-start"></div>
					    </div>
				    </div>
			    </div>
		    </div>
	    </div>
	    <div class="list_height plist-txt js-actionParent last">
	        <div class="pic"></div>
	        <div class="tit font14">结束时间<span class="font_red_light">*</span></div>
	        <div class="describe font13 qs-temp-date js-showActionSheet" data-type="end">
		        <span class="f-date-txt-end">
	        	<if condition="$Think.get.id eq ''">
	        		请选择
	        	<elseif condition="$info['todate']"/>
	        		至今
				<else/>
					{$info.endyear}年-{$info.endmonth}月
	        	</if>
			        </span>
				<input type="hidden" class="f-year-code-end" id="endyear" value="{$info['endyear']}">
				<input type="hidden" class="f-month-code-end" id="endmonth" value="{$info['endmonth']}">
				<input type="hidden" id="todate" value="{$info['todate']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
		    <!--BEGIN actionSheet-->
		    <div>
			    <div class="qs-mask" style="display:none"></div>
			    <div class="qs-actionsheet js-actionsheet">
				    <div class="qs-actionsheet-menu">
					    <div class="con-filter">
						    <div class="f-selected-group">
							    <div class="s-bar">
								    <div class="s-bar-title qs-left">结束时间</div>
								    <div class="qs-btn qs-btn-inline qs-btn-small qs-btn-border-orange qs-right js-cancelActionSheet js-todate">至今</div>
								    <div class="clear"></div>
							    </div>
							    <div class="s-list"></div>
						    </div>
						    <div class="f-box f-box-date-end"></div>
					    </div>
				    </div>
			    </div>
		    </div>
	    </div>
	    <!--<div class="list_height plist-txt notarrow">
	        <div class="pic"></div>
	        <div class="tit font14">工作职责<span class="font_red_light">*</span></div>
	        <div class="describe font13">
	    		        <input type="text" id="achievements" id="achievements" placeholder="请输入工作职责" value="{$info['achievements']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
	    </div> -->
	    <div class="split-block"></div>
	    <div class="textarea-txt">
			<textarea id="achievements" name="achievements" placeholder="请简述一下岗位职责和工作业绩，可使用人单位对你了解更多！" class="font13">{$info['achievements']}</textarea>
		</div>
		<div class="bottom_txt font12">
			<div class="llt">最多可输入1000字</div>
			<div class="rlt clear-content">清空</div>
		</div>
        <div class="btn-spacing">
        	<input type="hidden" id="id" value="{$info['id']}">
            <div id="J_saveresume" class="qs-btn qs-btn-blue font18" title="确定">确定</div>
        </div>
        <div class="split-block"></div>
	    <include file="public:footer_min" />
	    <script type="text/javascript">
	    	//清空内容
			$('.clear-content').on('click',function(){
				$('#achievements').val('');
			});

		    var tempDateArr = $('.qs-temp-date');
		    $.each(tempDateArr, function() {
			    var dtype = $(this).data('type');
			    var experienceDate = new Date();
			    var eyear = experienceDate.getFullYear();
			    var eyearMin = eyear - 59;
			    var dateHtml = '<div class="f-box-inner">';
			    for (var i = eyear; i >= eyearMin; i--) {
				    dateHtml += '<li><a class="font12 f-item f-item-year" href="javascript:;" data-code="' + i + '">' + i + '年</a></li>';
			    }
			    dateHtml += '</div>';
			    dateHtml += '<div class="f-box-inner">';
			    for (var i = 1; i <= 12; i++) {
				    dateHtml += '<li><a class="font12 f-item f-item-month js-cancelActionSheet" href="javascript:;" data-code="' + i + '">' + i + '月</a></li>';
			    }
			    dateHtml += '</div>';
			    $('.f-box-date-' + dtype).html(dateHtml);
			    $('.f-box-date-' + dtype + ' .f-item-year').eq(0).addClass('select');
			    $('.f-box-date-' + dtype + ' .f-item-month').eq(0).addClass('select');
			
			    $('.f-box-date-' + dtype + ' .f-item-year').on('click', function() {
				    $('.f-box-date-' + dtype + ' .f-item-year').removeClass('select');
				    $(this).addClass('select');
			    })
			    $('.f-box-date-' + dtype + ' .f-item-month').on('click', function() {
				    $('.f-box-date-' + dtype + ' .f-item-month').removeClass('select');
				    $(this).addClass('select');
				    // 赋值
				    $('.f-year-code-' + dtype).val($('.f-box-date-' + dtype + ' .f-item-year.select').data('code'));
				    $('.f-month-code-' + dtype).val($('.f-box-date-' + dtype + ' .f-item-month.select').data('code'));
				    $('.f-date-txt-' + dtype).text($('.f-box-date-' + dtype + ' .f-item-year.select').text() + '-' + $('.f-box-date-' + dtype + ' .f-item-month.select').text());
			    })
			    $('.js-todate').on('click', function() {
				    $('#todate').val('1');
				    $(this).closest('.js-actionParent').find('.f-year-code-end').val('');
				    $(this).closest('.js-actionParent').find('.f-month-code-end').val('');
				    $(this).closest('.js-actionParent').find('.f-date-txt-end').text('至今');
			    })
		    })
		    $(function(){
			    $(".js-showActionSheet").on("click", function(){
				    var $iosActionsheet = $(this).closest('.js-actionParent').find('.js-actionsheet');
				    var $iosMask = $(this).closest('.js-actionParent').find('.qs-mask');
				    $iosActionsheet.removeClass('qs-actionsheet-toggle');
				    $iosActionsheet.addClass('qs-actionsheet-toggle');
				    $iosMask.fadeIn(200);
				    $iosMask.on('click', hideActionSheet);
				    $(this).closest('.js-actionParent').find('.js-cancelActionSheet').on('click', hideActionSheet);
				    $(this).closest('.js-actionParent').find('.qs-actionsheet-cell').on('click', hideActionSheet);
				    function hideActionSheet() {
					    $(this).closest('.js-actionParent').find('.js-actionsheet').removeClass('qs-actionsheet-toggle');
					    $(this).closest('.js-actionParent').find('.qs-mask').fadeOut(200);
				    }
			    });
		    });
	    	$('#J_saveresume').die().live('click', function() {
				var companynameValue = $.trim($('#companyname').val());
	            var experiencenameValue = $.trim($('#jobs').val());
	            var startyearExpValue = $.trim($('#startyear').val());
	            var startmonthExpValue = $.trim($('#startmonth').val());
	            var endyearExpValue = $.trim($('#endyear').val());
	            var endmonthExpValue = $.trim($('#endmonth').val());
	            var todateExpValue = $.trim($('#todate').val());
	            var jobresponsValue = $.trim($('#achievements').val());
				var id = $.trim($('#id').val());
				var pid = "{$resume.id}";
				var news = "{$Think.get.news}";
				if (companynameValue == "") {
					qsToast({type:2,context: '请填写公司名称'});
					return false;
				}
				if (experiencenameValue == "") {
					qsToast({type:2,context: '请填写职位名称'});
					return false;
				}
				if (startyearExpValue == "") {
					qsToast({type:2,context: '请选择工作开始时间'});
					return false;
				}
				if (startmonthExpValue == "") {
					qsToast({type:2,context: '请选择工作开始月份'});
					return false;
				}
				if (!parseInt(todateExpValue)) {
					if (endyearExpValue == "") {
						qsToast({type:2,context: '请选择工作结束时间'});
						return false;
					}
					if (endmonthExpValue == "") {
						qsToast({type:2,context: '请选择工作结束月份'});
						return false;
					}
					if (wrongTime(startyearExpValue, startmonthExpValue, endyearExpValue, endmonthExpValue)) {
						qsToast({type:2,context: '工作开始时间需小于结束时间'});
						return false;
					};
				};
				if (jobresponsValue == "") {
					qsToast({type:2,context: '请填写工作职责'});
					return false;
				}
				$('#J_saveresume').val('保存中...').addClass('qs-btn-border-disabled');
	            // 提交表单
	            $.ajax({
	                url: "{:U('Personal/resume_edit_work')}",
	                type: 'POST',
	                dataType: 'json',
	                data: {id: id, pid: pid, companyname: companynameValue, jobs: experiencenameValue, startyear: startyearExpValue, startmonth: startmonthExpValue, endyear: endyearExpValue, endmonth: endmonthExpValue, todate: todateExpValue, achievements: jobresponsValue,news:news},
	                success:function(data){
	                    if (data.status == 1) {
	                        window.location.href = data.data.url;
	                    } else {
	                        qsToast({type:2,context: data.msg});
	                        $('#J_saveresume').val('保存').removeClass('qs-btn-border-disabled');
	                    }
	                },
	                error:function(result){
	                    $('#J_saveresume').val('保存').removeClass('qs-btn-border-disabled');
	                    qsToast({type:2,context: result.msg});
	                }
	            });
			    // 判断结束时间是否大于开始时间
			    function wrongTime(sYear, sMonth, eYear, eMonth) {
				    if (parseInt(sYear) > parseInt(eYear)) {
					    return true;
				    } else {
					    if (parseInt(sYear) == parseInt(eYear)) {
						    if (parseInt(sMonth) >= parseInt(eMonth)) {
							    return true;
						    } else {
							    return false;
						    }
					    } else {
						    return false;
					    }
				    }
			    }
	        });
	    </script>
	</body>
</html>